
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.MedicinePrice;
import cn.edu.scau.cmi.hombio.domain.MedicineStorage;
import cn.edu.scau.cmi.hombio.domain.MedicineSupplier;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class MedicinePriceServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected MedicinePriceService service;

	/**
	 * Instantiates a new MedicinePriceServiceTest.
	 *
	 */
	public MedicinePriceServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineStorage entity
	* 
	 */
	@Test
	public void deleteMedicinePriceMedicineStorage() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicinePriceMedicineStorage 
		Integer medicineprice_id = 0;
		Integer related_medicinestorage_id = 0;
		MedicinePrice response = null;
		response = service.deleteMedicinePriceMedicineStorage(medicineprice_id, related_medicinestorage_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicinePriceMedicineStorage
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicinePrice entity
	* 
	 */
	@Test
	public void saveMedicinePrice() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicinePrice 
		MedicinePrice medicineprice = new cn.edu.scau.cmi.hombio.domain.MedicinePrice();
		service.saveMedicinePrice(medicineprice);
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineSupplier entity
	* 
	 */
	@Test
	public void deleteMedicinePriceMedicineSupplier() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicinePriceMedicineSupplier 
		Integer medicineprice_id_1 = 0;
		Integer related_medicinesupplier_id = 0;
		MedicinePrice response = null;
		response = service.deleteMedicinePriceMedicineSupplier(medicineprice_id_1, related_medicinesupplier_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicinePriceMedicineSupplier
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineStorage entity
	* 
	 */
	@Test
	public void saveMedicinePriceMedicineStorage() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicinePriceMedicineStorage 
		Integer id = 0;
		MedicineStorage related_medicinestorage = new cn.edu.scau.cmi.hombio.domain.MedicineStorage();
		MedicinePrice response = null;
		response = service.saveMedicinePriceMedicineStorage(id, related_medicinestorage);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicinePriceMedicineStorage
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findMedicinePriceByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findMedicinePriceByPrimaryKey 
		Integer id_1 = 0;
		MedicinePrice response = null;
		response = service.findMedicinePriceByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findMedicinePriceByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Return a count of all MedicinePrice entity
	* 
	 */
	@Test
	public void countMedicinePrices() {
		Integer response = null;
		response = service.countMedicinePrices();
		// TODO: JUnit - Add assertions to test outputs of operation: countMedicinePrices
	}

	/**
	 * Operation Unit Test
	* Load an existing MedicinePrice entity
	* 
	 */
	@Test
	public void loadMedicinePrices() {
		Set<MedicinePrice> response = null;
		response = service.loadMedicinePrices();
		// TODO: JUnit - Add assertions to test outputs of operation: loadMedicinePrices
	}

	/**
	 * Operation Unit Test
	* Return all MedicinePrice entity
	* 
	 */
	@Test
	public void findAllMedicinePrices() {
		// TODO: JUnit - Populate test inputs for operation: findAllMedicinePrices 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<MedicinePrice> response = null;
		response = service.findAllMedicinePrices(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllMedicinePrices
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicinePrice entity
	* 
	 */
	@Test
	public void deleteMedicinePrice() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicinePrice 
		MedicinePrice medicineprice_1 = new cn.edu.scau.cmi.hombio.domain.MedicinePrice();
		service.deleteMedicinePrice(medicineprice_1);
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineSupplier entity
	* 
	 */
	@Test
	public void saveMedicinePriceMedicineSupplier() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicinePriceMedicineSupplier 
		Integer id_2 = 0;
		MedicineSupplier related_medicinesupplier = new cn.edu.scau.cmi.hombio.domain.MedicineSupplier();
		MedicinePrice response = null;
		response = service.saveMedicinePriceMedicineSupplier(id_2, related_medicinesupplier);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicinePriceMedicineSupplier
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
